﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_UpdatePerson')
	BEGIN
		DROP  Procedure  [esf_sso].P_UpdatePerson
	END

GO

CREATE Procedure [esf_sso].P_UpdatePerson
	@pID					BIGINT
	,@pFirstName			VARCHAR (40)
	,@pSecondName			VARCHAR (40) = NULL
	,@pSurName				VARCHAR (40)
	,@pLastName				VARCHAR (40) = NULL
	,@pBirthDate			DATETIME = NULL
	,@pGenderID				BIGINT
	,@pIdentificationTypeID BIGINT
	,@pIdentificationNumber VARCHAR (20)
	,@pEmail				VARCHAR (160) = NULL
	,@pEnterpriseID			BIGINT = NULL
	,@pOtherEnterprise		VARCHAR (60) = NULL
	,@pProfession			VARCHAR (200) = NULL
	,@pPosition				VARCHAR (200) = NULL
AS

	UPDATE [esf_sso].[Person]
	SET
		[FirstName] = @pFirstName
		,[SecondName] = @pSecondName
		,[SurName] = @pSurName
		,[LastName] = @pLastName
		,[BirthDate] = @pBirthDate
		,[GenderID] = @pGenderID
		,[IdentificationTypeID] = @pIdentificationTypeID
		,[IdentificationNumber] = @pIdentificationNumber
		,[Email] = @pEmail
		,[EnterpriseID] = @pEnterpriseID
		,[OtherEnterprise] = @pOtherEnterprise
		,Profession = @pProfession
		,Position = @pPosition
	WHERE	
		ID = @pID
	
GO